package com.tlxch.controller.teacher;

import com.tlxch.dto.TStudentdto;
import com.tlxch.dto.TStudto;
import com.tlxch.pojo.SStudent;
import com.tlxch.result.PageResult;
import com.tlxch.result.Result;
import com.tlxch.server.teacher.TstudentService;
import com.tlxch.vo.StuGradeMajorvo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "学生管理相关接口")
@Slf4j
@RestController
@RequestMapping("/teacher/student")
public class TstudenController {
    @Autowired
    TstudentService tstudentService;

    @PostMapping("/addstu")
    @ApiOperation("支持批量添加学生")
    public Result addstu(@RequestBody List<TStudentdto> tStudentdtoList){
        tstudentService.addstu(tStudentdtoList);
        return Result.success();
    }

    @GetMapping("/getGradeAndSpecialty")
    @ApiOperation("获取年级和专业")
    public Result<StuGradeMajorvo> getGradeAndSpecialty(){
        StuGradeMajorvo stuGradeMajorvo = tstudentService.getGradeAndSpecialty();
        return Result.success(stuGradeMajorvo);
    }

    @GetMapping("/getStuList")
    @ApiOperation("学生分页查询")
    public Result<PageResult> getStuList(TStudto tStudto){
        PageResult pageResult = tstudentService.pageQuery(tStudto);
        return Result.success(pageResult);
    }

    @PutMapping("/updateStu")
    @ApiOperation("更新学生信息")
    public Result updateStu(@RequestBody SStudent student){
        tstudentService.updateStu(student);
        return Result.success();
    }

}
